def solve(b1,b2):
if len(b1)!=len(b2):
return -1
for i in b1:
if not i in "0123456789":
return -1
for i in b2:
if not i in "0123456789":
return -1
v1=[int(i) for i in b1]
v2=[int(i) for i in b2]
v1.sort()
v2.sort()
a,b=0,0
tmp=0
ln=len(b1)
ans=""
while b<ln:
if v1[a]>v2[b]:
tmp+=1
else:
a+=1
b+=1
ans+=str(tmp)+"\n"
a,b=0,0
tmp=0
ln=len(v1)
while a<ln:
while b<ln and v1[a]>=v2[b]:
b+=1
if b<ln:
tmp+=1
b+=1
a+=1
ans+=str(tmp)
return ans
def doc(lst):
fn=[]
for i in lst:
b1,b2=i[0],i[1]
fn.append(solve(b1,b2))
return fn
n=int(input())
b1=input()
b2=input()
print(solve(b1,b2))
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
bool cmp(int a,int b)
{
return a>b;
}
int main()
{
int n;
char a[1005];
char b[1005];
while(scanf("%d",&n)!=EOF)
{
scanf("%s%s",a,b);
sort(a,a+n);
sort(b,b+n);
int x=0;
int y=0;
for(int i=0,j=0;j<n;j++)
{
if(b[j]>=a[i]) i++;
else x++;
}
for(int i=n-1,j=n-1;i>=0;i--)
{
if(b[j]>a[i])
{
j--;
y++;
}
}
printf("%d\n%d\n",x,y);
}
return 0;
}
96. Unique Binary Search Trees | 75. Sort Colors |
74. Search a 2D Matrix | 71. Simplify Path |
62. Unique Paths | 50. Pow(x, n) |
43. Multiply Strings | 34. Find First and Last Position of Element in Sorted Array |
33. Search in Rotated Sorted Array | 17. Letter Combinations of a Phone Number |
5. Longest Palindromic Substring | 3. Longest Substring Without Repeating Characters |
1312. Minimum Insertion Steps to Make a String Palindrome | 1092. Shortest Common Supersequence |
1044. Longest Duplicate Substring | 1032. Stream of Characters |
987. Vertical Order Traversal of a Binary Tree | 952. Largest Component Size by Common Factor |
212. Word Search II | 174. Dungeon Game |
127. Word Ladder | 123. Best Time to Buy and Sell Stock III |
85. Maximal Rectangle | 84. Largest Rectangle in Histogram |
60. Permutation Sequence | 42. Trapping Rain Water |
32. Longest Valid Parentheses | Cutting a material |
Bubble Sort | Number of triangles |